home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / MiniGames / JFS / JellyFishSwarmMG.as next >
Text File  |  2013-04-24  |  3KB  |  100 lines

  1. class MiniGames.JFS.JellyFishSwarmMG extends MiniGames.BaseMiniGame
  2. {
  3.    static var sSTATE_NORMAL = "Normal";
  4.    static var sSTATE_WHACKY = "Whacky";
  5.    static var nMAX_TIME = 24;
  6.    static var nSECOND_VALUE = 100;
  7.    static var nBUFFER_TIME = 10;
  8.    function JellyFishSwarmMG(_mcRef)
  9.    {
  10.       super(_mcRef);
  11.       this.nNbJellyFish = 0;
  12.       this.showInstructions();
  13.    }
  14.    function initMiniGame()
  15.    {
  16.       this.oPatrick = new MiniGames.JFS.JFSPatrick(this.mcRef.mcState.mcPatrick);
  17.       this.aJellyFishes = new Array();
  18.       for(var i in this.mcRef.mcState.mcContainer)
  19.       {
  20.          this.aJellyFishes.push(new MiniGames.JFS.JFSJellyFish(this.mcRef.mcState.mcContainer[i],this));
  21.          this.nNbJellyFish = this.nNbJellyFish + 1;
  22.       }
  23.    }
  24.    function setState(_sState)
  25.    {
  26.       super.setState(_sState);
  27.       if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME || this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
  28.       {
  29.          if(Main.getRef().isCheatClothesActivated())
  30.          {
  31.             this.mcRef.mcState.gotoAndStop(MiniGames.JFS.JellyFishSwarmMG.sSTATE_WHACKY);
  32.          }
  33.          else
  34.          {
  35.             this.mcRef.mcState.gotoAndStop(MiniGames.JFS.JellyFishSwarmMG.sSTATE_NORMAL);
  36.          }
  37.       }
  38.       else if(Main.getRef().isCheatClothesActivated())
  39.       {
  40.          this.mcRef.mcBack.gotoAndStop(MiniGames.JFS.JellyFishSwarmMG.sSTATE_WHACKY);
  41.       }
  42.       else
  43.       {
  44.          this.mcRef.mcBack.gotoAndStop(MiniGames.JFS.JellyFishSwarmMG.sSTATE_NORMAL);
  45.       }
  46.    }
  47.    function doUnPause()
  48.    {
  49.       super.doUnPause();
  50.       this.mcRef.stop();
  51.       this.mcRef.mcBack.stop();
  52.       if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME || this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
  53.       {
  54.          this.mcRef.mcState.stop();
  55.       }
  56.    }
  57.    function validateEndMiniGame()
  58.    {
  59.       if(this.nNbJellyFish == 0 && this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME)
  60.       {
  61.          this.setVictory();
  62.       }
  63.    }
  64.    function destroyMiniGame()
  65.    {
  66.       super.destroyMiniGame();
  67.       for(var i in this.aJellyFishes)
  68.       {
  69.          this.aJellyFishes[i].cleanUp();
  70.       }
  71.       this.oPatrick.cleanUp();
  72.    }
  73.    function calculateScore()
  74.    {
  75.       this.addScoreFromTimeLeft(MiniGames.JFS.JellyFishSwarmMG.nMAX_TIME,MiniGames.JFS.JellyFishSwarmMG.nSECOND_VALUE);
  76.    }
  77.    function decreaseJellyFishCount()
  78.    {
  79.       if(this.nNbJellyFish > 0)
  80.       {
  81.          this.nNbJellyFish = this.nNbJellyFish - 1;
  82.       }
  83.    }
  84.    function takeHook(_oJelly)
  85.    {
  86.       this.oPatrick.takeHook(_oJelly);
  87.    }
  88.    function MiniGame()
  89.    {
  90.       super.MiniGame();
  91.    }
  92.    function Victory()
  93.    {
  94.       if(this.mcRef.mcState.mcState._currentframe == this.mcRef.mcState.mcState._totalframes - MiniGames.JFS.JellyFishSwarmMG.nBUFFER_TIME)
  95.       {
  96.          this.bOver = true;
  97.       }
  98.    }
  99. }
  100.